﻿#region Using
using System;
using System.ComponentModel; 
#endregion

namespace AifMessageHeaderEditor.Lib.Data.File
{
    /// <summary>
    /// Information about the file.
    /// </summary>
    public class FileData : INotifyPropertyChanged, IDataBase
    {
        #region members and consts

        private string _sourceFilename;
        private string _destinationDirectory;
        private string _fileOwner;
        private string _fileOwnerName;

        //TODO: implement event Changed....
        public string FileOwnerName
        {
            set
            {
                if (value != this.FileOwnerName)
                {
                    _fileOwnerName = value;
                    NotifyPropertyChanged(AppCommon.AIF_FILE_SOURCE_FILEOWNERNAME);
                }
            }

            get { return _fileOwnerName; }
        }

        public string FileOwner
        {
            set
            {
                if (value != this.FileOwner)
                {
                    _fileOwner = value;
                    NotifyPropertyChanged(AppCommon.AIF_FILE_SOURCE_FILEOWNER);
                }
            }
            get { return _fileOwner; }
        }

        /// <summary>
        /// The Xml-file that contains the original data
        /// </summary>
        public string SourceFilename
        {
            set
            {
                if (value != this.SourceFilename)
                {
                    _sourceFilename = value;
                    NotifyPropertyChanged(AppCommon.AIF_FILE_SOURCE);
                }
            }
            get { return _sourceFilename; }
        }

        /// <summary>
        /// The file that needs to be saved in the Aif directory
        /// </summary>
        public string DestinationDirectory
        {
            set
            {
                if (value != this.DestinationDirectory)
                {
                    _destinationDirectory = value;
                    NotifyPropertyChanged(AppCommon.AIF_FILE_DESTINATION);
                }
            }
            get { return _destinationDirectory; }
        }

        #endregion

        #region Notification

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyChanges()
        {
            NotifyPropertyChanged(AppCommon.AIF_FILE_SOURCE);
            NotifyPropertyChanged(AppCommon.AIF_FILE_DESTINATION);
        }

        /// <summary>
        /// used for the databinding: notifies the controles that are binded 
        /// to the object or properties.
        /// </summary>
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion
    }
}
